﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CoseaBussinesQA;
using System.Configuration;

public partial class RegistrarUsuario : System.Web.UI.Page
{
    private static AppSettingsReader settings = new AppSettingsReader();
    string cadena = (string)settings.GetValue("Conexion2", typeof(string));

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnIngresar_Click(object sender, EventArgs e)
    {
        try
        {
            using (CoseaBussinesQA.BussinesQA c = new CoseaBussinesQA.BussinesQA(cadena))
            {
                Usuario usu = c.BuscaUsuario(txtUsuario.Text.Trim());
                if (usu.Password.Trim() == txtPassword.Text.Trim())
                {
                    UsuarioActual.Usuario = usu;
                    Response.Redirect("index.aspx");
                }
                else
                    lblError.Text = "Password invalido";
                txtPassword.Focus();

            }
        }
        catch (Exception)
        {
            lblError.Text = "Usuario no encontrado";
        }


        //CRMGenerales.Firmado = new Usuario { UsuariosId = 1, EmpleadosId = 1, Nombre = "vceja", Password = "14mayo1973" }; //leer y validad por codigo
        //Response.Redirect("index.aspx");
    }
}